define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'rugood/index' + location.search,
                
                    
                    multi_url: 'rugood/multi',
                    table: 'rugood',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                columns: [
                    [
                        {checkbox: true},
                        {field: 'id', title: __('Id')},
                        {field: 'sku', title: __('Sku')},
                        {field: 'channel_source', title: '渠道来源'},
                        {field: 'name', title: __('Cangku_id')},
                        {field: 'batch_number', title: '批号'},
                        {field: 'type', title: '类别'},
                        {field: 'location', title: '货物位置'},
                        {field: 'codebar', title: '条形码'},
                        {field: 'huohao', title: '货号'},
                        {field: 'mianshui', title: '免税编号'},
                        {field: 'in_num', title: __('In_num')},
                        {field: 'not_in_num', title: __('Not_in_num')},
                        {field: 'shengyu_num', title: __('Shengyu_num')},
                        {field: 'out_num', title: __('Out_num')},
                        {field: 'damage_num', title: __('Damage_num')},
                        {field: 'return_num', title: __('Return_num')},
                        {field: 'createtime', title: '创建时间', operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
                        {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});